package main;

import image.ImageUtils;

import javax.microedition.lcdui.Command;
import javax.microedition.lcdui.CommandListener;
import javax.microedition.lcdui.Displayable;
import javax.microedition.lcdui.Form;
import javax.microedition.lcdui.TextBox;

public class InputScreen extends TextBox implements CommandListener{
	private static final Command OK_COMMAND =
            new Command("OK", Command.OK, 0);
	MainMidlet midlet;
	DrawingCanvas imageCanvas;
	public InputScreen(MainMidlet midlet, DrawingCanvas imageCanvas) {
		super("File name", "pixel_art", 256, 0);
		addCommand(OK_COMMAND);
		setCommandListener(this);
		this.midlet = midlet;
		this.imageCanvas = imageCanvas;
		
	}

	public void commandAction(Command c, Displayable d) {
		// TODO Auto-generated method stub
		
		if (c == OK_COMMAND) {
            String filename = getString();
            ImageUtils.saveImage2File(imageCanvas.getOpaqueImage(), filename + ".png");
        	System.out.println("Saved");
        	midlet.show(imageCanvas);
        }
	}
	
/*
	public InputScreen() {
		super("Input");
		//this.append(new TextBox("", "Image", 0, 0));
		
		// TODO Auto-generated constructor stub
	}*/






}
